package com.han.fu.api.business.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.han.fu.api.business.model.ao.FollowAo;
import com.han.fu.api.business.model.ao.FollowPageAo;
import com.han.fu.api.business.model.vo.FollowVo;
import com.han.fu.api.business.service.IFollowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 关注接口
 *
 * @author: star
 * @date: 2021-08-12
 */
@RestController
public class FollowController {

    @Autowired
    IFollowService iFollowService;

    /**
     * 关注分页查询
     *
     * @param ao 分页查询条件
     * @return Page<FollowVo> 分页数据
     */
    @PreAuthorize("hasRole('tourist') OR hasRole('member') OR hasRole('admin')")
    @PostMapping("/follow/page")
    public Page<FollowVo> queryFollowPage(@Validated @RequestBody FollowPageAo ao) {
        return iFollowService.queryFollowPage(ao);
    }

    /**
     * 关注新增数据
     *
     * @param ao 数据
     */
    @PreAuthorize("hasRole('tourist') OR hasRole('member') OR hasRole('admin')")
    @PostMapping("/follow/add")
    public void addFollow(@Validated @RequestBody FollowAo ao) {
        iFollowService.addFollow(ao);
    }

}